package com.office.automate.schedule.jobs;

import java.util.List;

import com.office.automate.exception.framework.FrontierVisibleException;
import com.office.automate.frontier.utility.DataConversionUtility;
import com.office.automate.model.employee.Employee;
import com.office.automate.model.payrole.MonthlyEmployeePayrole;
import com.office.automate.service.def.employee.EmployeeService;
import com.office.automate.service.impl.employee.EmployeeServiceImplementer;
import com.office.automate.service.impl.payrole.EmployeePayroleServiceImplementer;

public class MonthlyProcessJob {

	public static void main(String[] args) {
		EmployeeService employeeService = new EmployeeServiceImplementer();
		DataConversionUtility dcu = new DataConversionUtility();
		try {
			List<Employee> employeeList = employeeService.getAllEmployeeDetails();
			for (Employee emp : employeeList) {
				MonthlyEmployeePayrole payrole = new MonthlyEmployeePayrole();
				double basicSalary = emp.getSalary();
				payrole.setBasicSalary(basicSalary);
				double epf_emp = (basicSalary * 10) / (double) 100;
				payrole.setEpfEmp(epf_emp);
				double epf_comp = (basicSalary * 15) / (double) 100;
				payrole.setEpfComp(epf_comp);
				double etf_comp = (basicSalary * 3) / (double) 100;
				payrole.setEtfComp(etf_comp);
				double payble_emp_Salary = (basicSalary * 90) / (double) 100;
				payrole.setBankPayment(payble_emp_Salary);
				payrole.setEmployeeId(emp.getEmployeeId());
				payrole.setBankName(emp.getBankName());
				payrole.setBankAccountNo(emp.getAccountNumber());
				payrole.setBillingPeriod(dcu.getCurentBillingPeriod());
				payrole.setBillingDate(dcu.getCurrentBillingDate());
				payrole.setPaymentMethod(emp.getPaymentType());
				new EmployeePayroleServiceImplementer().persistEmployeeSalaryDetails(payrole);
			}
		} catch (FrontierVisibleException e) {
			e.printStackTrace();
		}
	}
}
